package com.sugou.dao.support.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.sugou.dao.exceptions.DaoException;
import com.sugou.dao.support.ParamsStatement;

public class SearchStatement implements ParamsStatement,CharSequence {
	private static final long serialVersionUID = 2209466693407637417L;

	private String content;
	
	private List<? extends Serializable> params;
	
	public SearchStatement(String content,List<? extends Serializable> params) {
		if(StringUtils.isBlank(content)){
			throw new DaoException(new ErrorResInfo(-1, "空语句不能被执行"));
		}
		this.content=content;
		this.params=params;
	}
	
	public String getContent() {
		return this.content;
	}

	public List<? extends Serializable> getParams() {
		return this.params==null?new ArrayList<Serializable>():new ArrayList<Serializable>(params);
	}

	public int length() {
		return this.content.length();
	}

	public char charAt(int index) {
		return this.content.charAt(index);
	}

	public CharSequence subSequence(int start, int end) {
		return this.content.subSequence(start, end);
	}

	public String toString() {
		return this.content;
	}

	
}
